package com.whfc.wxmp.api.base.controller;

import com.whfc.base.dto.AppBannerDTO;
import com.whfc.common.base.BaseController;
import com.whfc.common.result.ListData;
import com.whfc.common.result.Result;
import com.whfc.common.result.ResultUtil;
import com.whfc.wxmp.annotation.CurrentWxUser;
import com.whfc.fuum.entity.WxUser;
import com.whfc.wxmp.api.base.service.WxBannerService;
import com.whfc.wxmp.util.RequestConetxtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : qzexing
 * @version : 1.0
 * @date : 2020/7/4 11:03
 */
@RestController
@RequestMapping("/mp/api/home/banner")
public class WxBannerController extends BaseController {

    @Autowired
    private WxBannerService bannerService;

    @GetMapping("/list")
    public Result list(@CurrentWxUser WxUser user,
                       @RequestParam("deptId") Integer deptId) {
        logger.info("WXMPUA|{}|{}|{}|{}|{}",
                user.getId(), RequestConetxtUtil.getAppType(), RequestConetxtUtil.getPage(),
                "获取banner列表", "{\"deptId\":\"" + deptId + "\"}");
        List<AppBannerDTO> list = bannerService.list(deptId);
        return ResultUtil.success(new ListData<>(list));
    }

}
